package com.iplant.pdm.service.po.bop;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.iplant.base.po.BasePO;
import com.iplant.base.po.enums.DBSchemas;
import com.iplant.base.utils.annotation.po.DBBasePO;
import com.iplant.base.utils.annotation.condition.DBCondition;
import com.iplant.base.utils.annotation.field.DBField;
import com.iplant.base.utils.annotation.join.DBJoin;
import com.iplant.pdm.service.basicenum.fpc.FPCRouteType;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 工艺集
 *
 * @author YouWang·Peng
 * 2023-7-26 14:55:31
 */
@DBBasePO(TableName = "fpc_routepart", Schemas = DBSchemas.PDM, CheckName = {"Code", "RouteID,Version,Name"}, CodeAuto =
        true, CodePrefix = "GYJ-",
        CodeNum = 4)
public class FPCRoutePart extends BasePO implements Serializable {

    /**
     * 序列号
     */
    private static final long serialVersionUID = 1L;

    @DBCondition
    @DBField
    public String Version = "";//工艺集版本号

    @DBCondition
    @DBField
    public int RouteID = 0; // 工艺版本ID

    @DBJoin(name = "TypeID", tableName = "fpc_route", tableAsName = "route1", Schemas = DBSchemas.PDM,
            MainTableField = "RouteID")
    public int RouteType = 0;

    @DBJoin(name = "Code", tableName = "fpc_route", tableAsName = "route1", Schemas = DBSchemas.PDM,
            MainTableField = "RouteID")
    public String RouteCode = "";
    @DBJoin(name = "Name", tableName = "fpc_route", tableAsName = "route1", Schemas = DBSchemas.PDM,
            MainTableField = "RouteID")
    public String RouteName = ""; // 工艺名称
    @DBJoin(name = "Version", tableName = "fpc_route", tableAsName = "route1", Schemas = DBSchemas.PDM,
            MainTableField = "RouteID")
    public String RouteVersion = "";

    @DBJoin(name = "LineID", tableName = "fpc_routeparent", tableAsName = "fpc_routeparent1", Schemas = DBSchemas.PDM
            , JoinIndex = 2,
            ConditionalJoin = "fpc_routeparent1.ID=route1.BOPParentID")
    public int LineID = 0;

    @DBJoin(name = "ProductID", tableName = "fpc_routeparent", tableAsName = "fpc_routeparent1", Schemas =
            DBSchemas.PDM, JoinIndex = 2,
            ConditionalJoin = "fpc_routeparent1.ID=route1.BOPParentID")
    public int ProductID = 0;

    /**
     * 车间ID
     */
    @DBCondition
    @DBField
    public int WorkShopID = 0;
    @DBJoin(name = "Name", tableName = "fmc_workshop", tableAsName = "workshop1", Schemas = DBSchemas.Basic,
            JoinIndex = 2,
            MainTableField = "WorkShopID")
    public String WorkShopName = "";
    /**
     * 车间编码
     */
    @DBJoin(name = "Code", tableName = "fmc_workshop", tableAsName = "workshop1", Schemas = DBSchemas.Basic,
            JoinIndex = 2,
            MainTableField = "WorkShopID")
    public String WorkShopCode = "";

    /**
     * 工区ID
     */
    @DBCondition
    @DBField
    public int WorkAreaID = 0;
    /**
     * 工区名称
     */
    @DBJoin(name = "Name", tableName = "fmc_workarea", tableAsName = "workarea1", Schemas = DBSchemas.Basic,
            JoinIndex = 3,
            MainTableField = "WorkAreaID")
    public String WorkAreaName = "";
    /**
     * 工区编码
     */
    @DBJoin(name = "Code", tableName = "fmc_workarea", tableAsName = "workarea1", Schemas = DBSchemas.Basic,
            JoinIndex = 3,
            MainTableField = "WorkAreaID")
    public String WorkAreaCode = "";

    /**
     * 工位ID
     */
    @DBCondition
    @DBField
    public int StationID = 0;
    /**
     * 工位名称
     */
    @DBJoin(name = "Name", tableName = "fmc_station", tableAsName = "station1", Schemas = DBSchemas.Basic,
            JoinIndex = 4,
            MainTableField = "StationID")
    public String StationName = "";
    /**
     * 工位编码
     */
    @DBJoin(name = "Code", tableName = "fmc_station", tableAsName = "station1", Schemas = DBSchemas.Basic,
            JoinIndex = 4,
            MainTableField = "StationID")
    public String StationCode = "";

    @DBField
    @DBCondition
    public int PartType = 0;//工艺集类型


    /**
     * 工艺产品类型  1 元件 0 非元件
     */
    @DBField
    @DBCondition
    public int ComponentType = 0;

    /**
     *
     */
    @DBField
    public String PartCode = "";


    public String PartEntityCode = "";
    public int PartEntityID = 0;
    public String PartEntityName = "";

    @DBField
    public float FQTY = 0.0f; // 单次加工批量

    @DBField
    public int Period = 0; // 工艺间隔（默认：-1）

    /**
     * 根据子项工序的间隔进行计算，算出最小间隔时长 更新工序时，自动计算
     */
    @DBField
    public int MinPeriod = 0; // 工艺间隔（默认：-1）

    @DBField
    public int MaxPeriod = 0;//最大间隔时长

    /**
     * 主线层级
     */
    @DBField
    public int OrderID = 0;

    @DBField
    public int PrevPartID = 0;// 上工艺集ID

    @DBJoin(name = "Name", tableName = "fpc_routepart", tableAsName = "routepart1", Schemas = DBSchemas.PDM,
            JoinIndex = 5,
            MainTableField = "PrevPartID")
    public String PrevPartName = "";

    /**
     * 转序控制类型（广机）
     */
    @DBField
    public int ChangeControl = 0;

    /**
     * 专检控制工位（广机）
     */
    @DBField
    public List<Integer> ControlPartID = new ArrayList<Integer>();

    public String ControlPartName = "";
    /**
     * 标准工时 工序工时相加
     */
    @DBField
    public Double StandardPeriod = 0.0;

    /**
     * 调整工时 新增字段 工序工时相加
     */
    @DBField
    public Double ActualPeriod = 0.0;

    public int ItemCount = 0;

    /**
     * 工艺集文件
     */
    @DBField
    public String PartFile = "";

    /**
     * 后工艺集ID
     */
    @DBField
    public List<Integer> NextPartID = new ArrayList<Integer>();

    public String NextPartName = "";
    /**
     * key RoutePartID Value : Condition value: 0 主线也是下个模块
     */
    @DBField
    public Map<String, String> NextPartIDMap = new HashMap<String, String>();// 下工艺集ID

//    @DBField
//    public String NextPartIDMapString = "";// 下工艺集ID

    public List<FPCRoutePartPoint> PartPointList = new ArrayList<>(); // 工艺工序列表

    /**
     * 换产批量
     */
    @DBField
    public double BatchFQTY = 0.0;

    /**
     * 排产间隔
     */
    @DBField
    public int SchedulePeriod = 0;


    /**
     * 辅助属性
     */
    public int OrderNumber = 0;

    /**
     *是否为关键工艺
     */
    @DBCondition
    @DBField
    public int KeyProcess=0;

    @JsonProperty("LineID")
    public int getLineID() {
        return LineID;
    }

    public void setLineID(int lineID) {
        LineID = lineID;
    }

    @JsonProperty("ProductID")
    public int getProductID() {
        return ProductID;
    }

    public void setProductID(int productID) {
        ProductID = productID;
    }

    @JsonProperty("OrderNumber")
    public int getOrderNumber() {
        return OrderNumber;
    }

    public void setOrderNumber(int orderNumber) {
        OrderNumber = orderNumber;
    }

    @JsonProperty("RouteType")
    public int getRouteType() {
        return RouteType;
    }

    public void setRouteType(int routeType) {
        RouteType = routeType;
    }

    @JsonProperty("BatchFQTY")
    public double getBatchFQTY() {
        return BatchFQTY;
    }

    public void setBatchFQTY(double batchFQTY) {
        BatchFQTY = batchFQTY;
    }

    @JsonProperty("SchedulePeriod")
    public int getSchedulePeriod() {
        return SchedulePeriod;
    }

    public void setSchedulePeriod(int schedulePeriod) {
        SchedulePeriod = schedulePeriod;
    }

    @JsonProperty("Version")
    public String getVersion() {
        return Version;
    }

    public void setVersion(String version) {
        Version = version;
    }

    @JsonProperty("RouteID")
    public int getRouteID() {
        return RouteID;
    }

    public void setRouteID(int routeID) {
        RouteID = routeID;
    }

    @JsonProperty("RouteCode")
    public String getRouteCode() {
        return RouteCode;
    }

    public void setRouteCode(String routeCode) {
        RouteCode = routeCode;
    }

    @JsonProperty("RouteName")
    public String getRouteName() {
        return RouteName;
    }

    public void setRouteName(String routeName) {
        RouteName = routeName;
    }

    @JsonProperty("RouteVersion")
    public String getRouteVersion() {
        return RouteVersion;
    }

    public void setRouteVersion(String routeVersion) {
        RouteVersion = routeVersion;
    }

    @JsonProperty("WorkShopID")
    public int getWorkShopID() {
        return WorkShopID;
    }

    public void setWorkShopID(int workShopID) {
        WorkShopID = workShopID;
    }

    @JsonProperty("WorkShopName")
    public String getWorkShopName() {
        return WorkShopName;
    }

    public void setWorkShopName(String workShopName) {
        WorkShopName = workShopName;
    }

    @JsonProperty("WorkShopCode")
    public String getWorkShopCode() {
        return WorkShopCode;
    }

    public void setWorkShopCode(String workShopCode) {
        WorkShopCode = workShopCode;
    }

    @JsonProperty("WorkAreaID")
    public int getWorkAreaID() {
        return WorkAreaID;
    }

    public void setWorkAreaID(int workAreaID) {
        WorkAreaID = workAreaID;
    }

    @JsonProperty("WorkAreaName")
    public String getWorkAreaName() {
        return WorkAreaName;
    }

    public void setWorkAreaName(String workAreaName) {
        WorkAreaName = workAreaName;
    }

    @JsonProperty("WorkAreaCode")
    public String getWorkAreaCode() {
        return WorkAreaCode;
    }

    public void setWorkAreaCode(String workAreaCode) {
        WorkAreaCode = workAreaCode;
    }

    @JsonProperty("StationID")
    public int getStationID() {
        return StationID;
    }

    public void setStationID(int stationID) {
        StationID = stationID;
    }

    @JsonProperty("StationName")
    public String getStationName() {
        return StationName;
    }

    public void setStationName(String stationName) {
        StationName = stationName;
    }

    @JsonProperty("StationCode")
    public String getStationCode() {
        return StationCode;
    }

    public void setStationCode(String stationCode) {
        StationCode = stationCode;
    }

    @JsonProperty("PartType")
    public int getPartType() {
        return PartType;
    }

    public void setPartType(int partType) {
        PartType = partType;
    }

    @JsonProperty("FQTY")
    public float getFQTY() {
        return FQTY;
    }

    public void setFQTY(float FQTY) {
        this.FQTY = FQTY;
    }

    @JsonProperty("Period")
    public int getPeriod() {
        return Period;
    }

    public void setPeriod(int period) {
        Period = period;
    }

    @JsonProperty("OrderID")
    public int getOrderID() {
        return OrderID;
    }

    public void setOrderID(int orderID) {
        OrderID = orderID;
    }

    @JsonProperty("PrevPartID")
    public int getPrevPartID() {
        return PrevPartID;
    }

    public void setPrevPartID(int prevPartID) {
        PrevPartID = prevPartID;
    }

    @JsonProperty("PrevPartName")
    public String getPrevPartName() {
        return PrevPartName;
    }

    public void setPrevPartName(String prevPartName) {
        PrevPartName = prevPartName;
    }

    @JsonProperty("ChangeControl")
    public int getChangeControl() {
        return ChangeControl;
    }

    public void setChangeControl(int changeControl) {
        ChangeControl = changeControl;
    }

    @JsonProperty("ControlPartID")
    public List<Integer> getControlPartID() {
        return ControlPartID;
    }

    public void setControlPartID(List<Integer> controlPartID) {
        ControlPartID = controlPartID;
    }

    @JsonProperty("ControlPartName")
    public String getControlPartName() {
        return ControlPartName;
    }

    public void setControlPartName(String controlPartName) {
        ControlPartName = controlPartName;
    }

    @JsonProperty("StandardPeriod")
    public Double getStandardPeriod() {
        return StandardPeriod;
    }

    public void setStandardPeriod(Double standardPeriod) {
        StandardPeriod = standardPeriod;
    }

    @JsonProperty("ActualPeriod")
    public Double getActualPeriod() {
        return ActualPeriod;
    }

    public void setActualPeriod(Double actualPeriod) {
        ActualPeriod = actualPeriod;
    }

    @JsonProperty("ItemCount")
    public int getItemCount() {
        return ItemCount;
    }

    public void setItemCount(int itemCount) {
        ItemCount = itemCount;
    }

    @JsonProperty("PartFile")
    public String getPartFile() {
        return PartFile;
    }

    public void setPartFile(String partFile) {
        PartFile = partFile;
    }

    @JsonProperty("NextPartID")
    public List<Integer> getNextPartID() {
        return NextPartID;
    }

    public void setNextPartID(List<Integer> nextPartID) {
        NextPartID = nextPartID;
    }

    @JsonProperty("NextPartName")
    public String getNextPartName() {
        return NextPartName;
    }

    public void setNextPartName(String nextPartName) {
        NextPartName = nextPartName;
    }

    @JsonProperty("NextPartIDMap")
    public Map<String, String> getNextPartIDMap() {
        return NextPartIDMap;
    }

    public void setNextPartIDMap(Map<String, String> nextPartIDMap) {
        NextPartIDMap = nextPartIDMap;
    }

    @JsonProperty("PartPointList")
    public List<FPCRoutePartPoint> getPartPointList() {
        return PartPointList;
    }

    public void setPartPointList(List<FPCRoutePartPoint> partPointList) {
        PartPointList = partPointList;
    }

    @JsonProperty("PartCode")
    public String getPartCode() {
        return PartCode;
    }

    public void setPartCode(String partCode) {


        PartCode = partCode;
    }

    @JsonProperty("MaxPeriod")
    public int getMaxPeriod() {
        return MaxPeriod;
    }

    public void setMaxPeriod(int maxPeriod) {
        MaxPeriod = maxPeriod;
    }

    @JsonProperty("MinPeriod")
    public int getMinPeriod() {
        return MinPeriod;
    }

    public void setMinPeriod(int minPeriod) {
        MinPeriod = minPeriod;
    }

    @JsonProperty("PartEntityCode")
    public String getPartEntityCode() {

        switch (FPCRouteType.getEnumType(RouteType)) {

            case RoutePartWorkshop:
                PartEntityCode = WorkShopCode;
                break;
            case RoutePartWorkArea:
                PartEntityCode = WorkAreaCode;
                break;
            case RoutePartStation:
                PartEntityCode = StationCode;
                break;
            case RoutePartPoint:
            case Default:
                break;
        }
        return PartEntityCode;
    }

    public void setPartEntityCode(String partEntityCode) {
        PartEntityCode = partEntityCode;
    }

    @JsonProperty("PartEntityID")
    public int getPartEntityID() {
        switch (FPCRouteType.getEnumType(RouteType)) {

            case RoutePartWorkshop:
                PartEntityID = WorkShopID;
                break;
            case RoutePartWorkArea:
                PartEntityID = WorkAreaID;
                break;
            case RoutePartStation:
                PartEntityID = StationID;
                break;
            case RoutePartPoint:
            case Default:
                break;
        }
        return PartEntityID;
    }

    public void setPartEntityID(int partEntityID) {
        PartEntityID = partEntityID;
    }

    @JsonProperty("PartEntityName")
    public String getPartEntityName() {
        switch (FPCRouteType.getEnumType(RouteType)) {

            case RoutePartWorkshop:
                PartEntityName = WorkShopName;
                break;
            case RoutePartWorkArea:
                PartEntityName = WorkAreaName;
                break;
            case RoutePartStation:
                PartEntityName = StationName;
                break;
            case RoutePartPoint:
            case Default:
                break;
        }
        return PartEntityName;
    }

    public void setPartEntityName(String partEntityName) {
        PartEntityName = partEntityName;
    }

    @JsonProperty("ComponentType")
    public int getComponentType() {
        return ComponentType;
    }

    public void setComponentType(int componentType) {
        ComponentType = componentType;
    }

    @JsonProperty("KeyProcess")
    public int getKeyProcess() {
        return KeyProcess;
    }

    public void setKeyProcess(int keyProcess) {
        KeyProcess = keyProcess;
    }
}
